#ifndef _GWBASE_BASE_COUNTDOWN_LATCH_
#define  _GWBASE_BASE_COUNTDOWN_LATCH_
#include "gwbase/base/condvar.h"
#include "gwbase/base/mutex.h"

namespace dicom {

class CountdownLatch {
 public:
  CountdownLatch(int count)
      : cond_(&mu_),
      count_(count),
      remain_(count_)
  { }

  void Down();
  void Wait();

 private:
  Mutex mu_;
  CondVar cond_;
  int count_;
  int remain_;
};

}

#endif //  _GWBASE_BASE_COUNTDOWN_LATCH_
